/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sudoku;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseListener;
import javax.swing.*;

/**
 *
 * @author sabrina
 */
public final class TableroSudoku9x9V1 extends javax.swing.JFrame implements IView {
    
    
     public static JTextField[] text1 = new JTextField[81];
     NivelYTamanio nyt = new NivelYTamanio();    
     JPanel jpanel = (JPanel) this.getContentPane();
     static JPanelConFondo img=new JPanelConFondo();
       
           
    
    

    /**
     * Creates new form TableroS
     */
    public TableroSudoku9x9V1() {
         //ImagenFondo imagen=new ImagenFondo();
        //imagen.setImage("/imagenes/wallpaper-ralladura.jpg");
        //setContentPane(imagen);
        
        initComponents();     
      
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
     public void initComponents() {

      
        jSeparator10 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator11 = new javax.swing.JSeparator();
        jSeparator8 = new javax.swing.JSeparator();
        jSeparator12 = new javax.swing.JSeparator();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

      

        jMenu1.setText("Archivo");

        jMenuItem1.setText("Iniciar juego");
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Salir");
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Partida");

        jMenuItem3.setText("Sugerir jugada");
        jMenu2.add(jMenuItem3);

        jMenuItem4.setText("Verificar jugada");
        jMenu2.add(jMenuItem4);

        jMenuItem5.setText("Resolver");
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Top-ten");

        jMenuItem6.setText("Top-ten");
        jMenu3.add(jMenuItem6);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Otros");

        jMenuItem7.setText("Reglas del juego");
        jMenu4.add(jMenuItem7);

        jMenuItem8.setText("Otros sudokus");
        jMenu4.add(jMenuItem8);

        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);
        
       //matriz textfield
       getContentPane().setLayout(new GridLayout(9,9));
        
          for(int i = 0; i < 81; i++) {                  
                
                    text1[i] = new JTextField();    //Llemanos el array de cajas de texto
                      //(6) PROPIEDADES DE LOS CONTROLES                       
    
                    text1[i].setBounds(new Rectangle(100, (i+1)*35, 60, 25));
                    
                   jpanel.add(text1[i], null);
             }
      
           
               //PROPIEDADES 
              
              setSize(500,500); 
              setTitle("Sudoku");               
              setVisible(true);

        //boton INICIAR PARTIDA      
        LoginListener buttonListener1 = new LoginListener();
    	IController loginController1 = new IniciarNivel9x9V1();
    	loginController1.setView(this);
    	buttonListener1.associate(jMenuItem1, loginController1);
        //boton resolver
        LoginListener buttonListener2 = new LoginListener();
    	IController loginController2 = new ResolverController9x9V1();
    	loginController2.setView(this);
    	buttonListener2.associate(jMenuItem5, loginController2);
        //boton REGLAS
        LoginListener buttonListener3 = new LoginListener();
    	IController loginController3 = new ReglasController1();
    	loginController3.setView(this);
    	buttonListener3.associate(jMenuItem7, loginController3);
        //boton OTROS SUDOKUS
        LoginListener buttonListener4 = new LoginListener();
    	IController loginController4 = new OtrosSudokus1();
    	loginController4.setView(this);
    	buttonListener4.associate(jMenuItem8, loginController4);
        //boton TOPTEN
        LoginListener buttonListener5 = new LoginListener();
    	IController loginController5 = new TopTenController9x9V1();
    	loginController5.setView(this);
    	buttonListener4.associate(jMenuItem6, loginController5);
        //boton VERIFICAR
        LoginListener buttonListener6 = new LoginListener();
    	IController loginController6 = new VerificarController9x9V1();
    	loginController6.setView(this);
    	buttonListener6.associate(jMenuItem4, loginController6);
        //boton Sugerir
        LoginListener buttonListener7 = new LoginListener();
    	IController loginController7 = new SugerirController9x9V1();
    	loginController7.setView(this);
    	buttonListener7.associate(jMenuItem3, loginController7);
        
         //boton salir
        jMenuItem2.addActionListener(new ActionListener() { 
            public void actionPerformed(ActionEvent ae) { 
                System.exit(0); // Y la acción es que salga cuando lo pulsemos 
            } 
        } );
        
         
      
        
       
    }// </editor-fold>
    
   public void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {
         char car = evt.getKeyChar();
        if((car<'0' || car>'9')) evt.consume();
    }
     

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TableroSudoku6x6V1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TableroSudoku6x6V1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TableroSudoku6x6V1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TableroSudoku6x6V1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
         
                 //cargarMatrizN1();
                //mostrarMatriz(matriz);
                new TableroSudoku9x9V1().setVisible(true);
              
               // pasarMatrizATablero(matriz);
                
                
            }
           
        });
        
        
    }
    // Variables declaration - do not modify

    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    
     public void present(String model) {
		JOptionPane.showMessageDialog(null, model);
	}
}


